Skip to content

sdk: record the wrapped exception's type on its event - #82

Open
eunomie wants to merge 1 commit into
mainfrom
exception-review-fixer-standalone-7509e311
Open

eunomie wants to merge 1 commit into
mainfrom
exception-review-fixer-standalone-7509e311

Conversation

@eunomie

@eunomie eunomie commented Nov 5, 2026

Copy link
Copy Markdown
Member

record_exception now sets exception.type on the event of the recording Python exception span to the qualified type of the exception that Module.call wrapped in FunctionError. The override applies only when the exception is exactly FunctionError with an explicit __cause__. Subclasses, wrappers without a cause, and implicit __context__ keep the wrapper's type.

The recorded exception is still the FunctionError wrapper, so the event's message and chained stacktrace are unchanged. The Dagger error payload is also unchanged: the span's event shows the immediate cause's type, while the Dagger error still reports FunctionError.

The new tests/mod/test_exceptions.py goes through the real Module.call path for sync and async functions and records spans with an in-memory OTel exporter.

Checked from sdk/:

  • uv run --frozen --group dev pytest -q tests/mod/test_exceptions.py
  • uv run --frozen --group dev pytest -q tests/mod/test_results.py -m "not slow" (run on the previous revision; the final revision only renames a local variable and edits a test comment)
  • ruff check and ruff format --check on the two changed files

Not checked: engine and integration execution were not run.

Separate follow-up: generated Dang entrypoints run python -m dagger.mod call, which does not call this recorder. They would need their own exception event.

Signed-off-by: Yves Brissaud <yves@dagger.io>
@eunomie
eunomie marked this pull request as ready for review November 10, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant